// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:'sudden-3gzfypks0b9196f8'
})

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const db = cloud.database()
  const collectionDirection = db.collection('subben_pay')
  // const $ = db.command.aggregate
  const directions = await collectionDirection.aggregate()
      .project({
        _id:0
      })
      .sort({
        time:-1
      })
      .end()
  console.log(directions)
  
  return {
    event,
    directions
  }
}